package com.qfedu.tower.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qfedu.common.R;
import com.qfedu.defect.task.dto.DefectTaskDto;
import com.qfedu.defect.task.pojo.DefectTask;
import com.qfedu.tower.dto.TowerDTO;
import com.qfedu.tower.dto.TowerStateDto;
import com.qfedu.tower.pojo.Tower;
import com.qfedu.tower.service.TowerService;
import com.qfedu.user.dto.StateDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 功能：
 * 作者：zwf
 * 日期：2024/6/13 20:43
 */
@RestController
@RequestMapping("/tower")
public class TowerController {

    @Autowired
    private TowerService towerService;


    @GetMapping
    public R<Page<Tower>> getTowers(TowerDTO towerDTO){
        return R.ok(towerService.getTowers(towerDTO));
    }

    @PostMapping
    public R<Boolean> addTower(@RequestBody Tower tower){
        //由于没有人写线路，这里直接写死
        tower.setLineId("EL349845734952960");
        return R.ok(towerService.saveTower(tower));
    }

    @PutMapping
    public R<Boolean> updateTower(@RequestBody Tower tower){
        return R.ok(towerService.updateById(tower));
    }

    @DeleteMapping("/{id}")
    public R<Boolean> deleteTower(@PathVariable("id") String id){
        return R.ok(towerService.removeById(id));
    }

    @PutMapping("/state")
    public R<Boolean> changeUseState(@RequestBody TowerStateDto towerStateDto){
        return R.ok(towerService.changeUseState(towerStateDto));
    }
}
